<?php
include("head.php");
$sql = "SELECT * FROM Article WHERE status<2 ORDER BY `id` DESC limit 6";
$result=mysqli_query($conn,$sql);
$arr = array();
while($row=mysqli_fetch_array($result, MYSQLI_NUM)){
    $arr[]=$row;
}
?>
<!DOCTYPE html>
<html lang="en">

<div class="am-g tpl-g">
    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">

        <div class="container-fluid am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                    <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span> 管理员首页 <small>Admin</small></div>
                    <p class="page-header-description">管理所有用户，以及他们发表的文章。禁用非法用户</p>
                </div>
            </div>

        </div>

        <div class="row-content am-cf">


            <div class="row am-cf">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-4 widget-margin-bottom-lg ">
                    <div class="tpl-user-card am-text-center widget-body-lg">
                        <div class="tpl-user-card-title">
                            <?php echo $_SESSION['username'];?>
                        </div>
                        <div class="achievement-subheading">
                            <?php
                                if($_SESSION['id']==1)
                                    echo "超级管理员";
                                else
                                    echo "普通管理员";
                            ?>
                        </div>
                        <img class="achievement-image" src="assets/img/user07.png" alt="">
                        <div class="achievement-description">
                            最新发布的文章
                        </div>
                    </div>
                </div>

                <div class="am-u-sm-12 am-u-md-12 am-u-lg-8 widget-margin-bottom-lg">

                    <div class="widget am-cf widget-body-lg">

                        <div class="widget-body  am-fr">
                            <div class="am-scrollable-horizontal ">
                                <table width="100%" class="am-table am-table-compact am-text-nowrap tpl-table-black " id="example-r">
                                    <thead>
                                    <tr>
                                        <th>文章标题</th>
                                        <th>作者</th>
                                        <th>时间</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach($arr as $data):?>
                                        <tr class="gradeX">
                                            <td><?php echo $data[4];?></td>
                                            <td><?php echo $data[2];?></td>
                                            <td><?php echo $data[5];?></td>
                                            <td><?php if($data[7]==1){echo "正常";}else{echo "禁用";}?></td>
                                            <td>
                                                <div class="tpl-table-black-operation">
                                                    <?php if($data[7]==1)
                                                        echo"
                                                        <a href='common.php?id=$data[0]&kind=2'>
                                                        <i class='am-icon-pencil'></i> 禁用
                                                        </a>";
                                                    else
                                                        echo "
                                                        <a href='common.php?id=$data[0]&kind=7'>
                                                        <i class='am-icon-pencil'></i> 显示
                                                        </a>";
                                                    ?>
                                                    <a href="detail.php?id=<?php echo $data[0];?>">
                                                        <i class="am-icon-pencil"></i> 查看
                                                    </a>
                                                    <a href="common.php?id=<?php echo $data[0];?>&kind=1" class="tpl-table-black-operation-del">
                                                        <i class="am-icon-trash"></i> 删除
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach;?>
                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
</html>